from thosttraderapi import THOST_FTDC_D_Buy as Buy
from thosttraderapi import THOST_FTDC_D_Sell as Sell
# from tqsdk.tafunc import crossup,crossdown,every
#指标解释
#https://doc.shinnytech.com/tqsdk/latest/reference/tqsdk.tafunc.html
ctp_ZG_config={
   'investor_id': '8600276',
   'broker_id':'5300',
   'password':'cc9200',
   'trader_server':'tcp://180.166.58.211:41255',
   'port':41273,
   'app_id':'client_zgjyhft_1.0.0',
   'auth_code':'GKZNS2NU081BOIA7',
}
ctp_BC_config={
   'investor_id': '601230875',
   'broker_id':'0001',
   'password':'czp666666',
   'trader_server':'tcp://222.68.181.35:51205',
   'app_id':'client_bcjyhft_1.0.0',
   'auth_code':'EQC9HUWVKNE1Y8JV',
}
ctp_DC_config={
   'investor_id': '9020659',
   'broker_id':'9099',
   'password':'czp666666',
   'trader_server':'tcp://103.192.214.78:51205',
   'app_id':'client_jyhtf_1.0.0',
   'auth_code':'ZZOHMNBUCPXPII8K',
}
ctp_simnow_config={
  "investor_id": "086759",
  "broker_id": "9999",
  "password": "091297",
  "md_server": "tcp://180.168.146.187:10131",
  "trader_server": "tcp://180.168.146.187:10130",
  "app_id": "simnow_client_test",
  "auth_code": "0000000000000000"
}
orderStatusDict={
   '0':'全部成交',
   '1':'部分成交还在队列中',
   '2':'部分成交不在队列中',
   '3':'未成交还在队列中',
   '4':'未成交不在队列中',
   '5':'撤单',
   'a':'未知',
}
OffsetFlagDict={
   '0':'买',
   '1':'卖',
}
OpenCloseFlagDict={
   '0':'开',
   '1':'平',
   '2':'强平',
   '3':'平今',
   '4':'平昨',
   '5':'强减',
   '6':'本地强平',
}
OrderSubmitStatusDict={
   '0':'已经提交',
   '1':'撤单已经提交',
   '2':'修改已经提交',
   '3':'已经接受',
   '4':'报单已经被拒绝',
   '5':'撤单已经被拒绝',
   '6':'改单已经被拒绝',
}
user_info={
    "userinfo":{
        "TQ_username": "cc9200",
         "TQ_password": "cc9200"
        },

    "IDtoMiniprice":{
                       "rb":1,"zn":5,"ag":1,"bu":1,"sp":2,"ss":10,"fu":1,'ru':5,  #上海
                        "i":0.5,"m":1,"p":2,"eg":1,"l":1,"v":1,"pg":1,"c":1,#大连
                        "SR":1,"TA":2,"SA":2,"FG":1,'CF':5,"MA":1,#郑州
                        "lu":1,"OI":1,"sc":0.1,#能源
                },
    "IDtoRatio":{#品种杠杆
                       "rb":10,"zn":5,"ag":15,"bu":10,"sp":10,"ss":10,"fu":10,'ru':10,  #上海
                        "i":100,"m":10,"p":10,"eg":10,"l":5,"v":5,"pg":20,"c":10,#大连
                        "SR":10,"TA":5,"SA":20,"FG":20,'CF':5,"MA":10,"OI":10,#郑州
                        "lu":10,"sc":1000,#能源
                },
                #逐品种，逐策略，检查参数，添加策略，具体品种具体分析
               #STD精确到小数点后1位，
               #注意判定信号之间的逻辑关系 产生好价位的信号放前面,不考虑时间的条件放前面
               #没有经过测试的策略，上线亏4000，思考漏洞  警惕单边大行情提前蹲守，防止大亏
               #大亏单子特点：开仓后，成交活跃，小亏，马上亏损扩大
               #不要怕小亏，小亏不影响，防的是大亏
               #曾经大赚的品种后来会大亏，所以盈利加仓不科学，最好是各品种均衡，用均衡对抗亏损
               #一个品种一专赚100，十个一天赚1000
               #测试策略：当前分钟末成交量，超过前五分钟最高成交量的1.5倍，且超过某个数值（品种而异）
               #策略原则，反转有空间，有反转预兆
               #连续；两根线破轨，后一根量小，高度小
               #策略 红三兵
    "instrumenID_dc":{
            "rb2310": {'volume':4,'volumeTuple':(2,2),'boll_N':10,'boll_P':2.1,"exchange": "SHFE", "miniPrice": 1, "Ratio": 10, "code": "rb",
            'conditionList':[
               #下轨   STD维持在5以上达到一定时间，减小boll_P
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-3 and v['std_ls'].iloc[-2]>2.5},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'两根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-13 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>6.5 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']< 25 and v['curSecondNum']>45},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]> v['std_ls'].iloc[-3]>4 and v['BoDongCount']< 30},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3.5 and v['std']>5 and any([v['kline'].iloc[i]['low']<v['boll'].iloc[i]['bottom'] for i in range(-4,-1)]) and v['curSecondNum']> 45},
               # {'res':{'direction':Buy,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'10',},
               #  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['high'])/v['miniPrice']<-10 and v['curSecondNum']> 45},
               # {'res':{'direction':Buy,'profitCoin':3,'tragyName':'远距离破轨','tragyArg':'10','volume':1},
               #  'condition':lambda v:v['blowInBottom'] and (v['kline'].iloc[-3]['close']-v['boll'].iloc[-3]['bottom'])/v['miniPrice']>6 and v['curSecondNum']> 20},
               
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差 波动率','tragyArg':'BoDongCount>40 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4 and v['curSecondNum']>45 and v['BoDongCount']> 30 and v['std']>4.5},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'爆量见底','tragyArg':'vol>15000 and std_1>3.5','volume':1},
                'condition':lambda v:(v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-6 and v['std_ls'].iloc[-2]>3.5 and v['CurVolume']>15000 and v['CurVolume']>1.5*v['kline'].iloc[-5:-1]['volume'].max() and v['curSecondNum']> 45},
               
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+3 and v['std_ls'].iloc[-2]>2.5},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>6 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']<25 and v['curSecondNum']>45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]> v['std_ls'].iloc[-3]>4 and v['BoDongCount']< 30},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['std']>5 and any([v['kline'].iloc[i]['high']>v['boll'].iloc[i]['top'] for i in range(-4,-1)]) and v['curSecondNum']> 45},
               # {'res':{'direction':Sell,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'10',},
               #  'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']>10 and v['curSecondNum']> 45},
                {'res':{'direction':Sell,'profitCoin':5,'tragyName':'两根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-2]['low'])/v['miniPrice']>13 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 标准差 波动率','tragyArg':'BoDongCount>40 and std>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['BoDongCount']> 40 and v['std']>4},
              {'res':{'direction':Sell,'profitCoin':5,'tragyName':'爆量见顶','tragyArg':'vol>15000 and std_1>3.5','volume':1},
                'condition':lambda v:(v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']>6 and v['std_ls'].iloc[-2]>3.5 and v['CurVolume']>15000 and v['CurVolume']>1.5*v['kline'].iloc[-5:-1]['volume'].max() and v['curSecondNum']> 45},
               ],
            }, 
            "bu2308": {'volume':2,'volumeTuple':(1,1),'boll_N':8,'boll_P':2,"exchange": "SHFE", "miniPrice": 1, "Ratio": 10, "code": "bu",
                  'conditionList':[
               #下轨
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-4 and v['std_ls'].iloc[-2]>3},
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'下轨 标准差 ','tragyArg':'[-2]>3 and std>5'},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3.5 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差 ','tragyArg':'[-2]>3 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4.2 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>8 and v['std']<v['maxSTD']*0.8 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-5:].min()>4 and v['BoDongCount']< 30},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['std']>5 and any([v['kline'].iloc[i]['low']<v['boll'].iloc[i]['bottom'] for i in range(-5,-1)]) and v['curSecondNum']> 45},    
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'单根线高度超过','tragyArg':'13',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-12  and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'两根线高度超过','tragyArg':'15',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-16 and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'远距离破轨','tragyArg':'10','volume':3},
                'condition':lambda v:v['blowInBottom']and v['std']>4 and (v['kline'].iloc[-3]['close']-v['boll'].iloc[-3]['bottom'])/v['miniPrice']>3 and v['curSecondNum']> 50},
               
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+4 and v['std_ls'].iloc[-2]>3},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 标准差 ','tragyArg':'[-3]>3 and std>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'下轨 标准差 ','tragyArg':'iloc[-3]>4 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>6.5 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']<25},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-5:].min()>4 and v['BoDongCount']< 30},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['std']>5 and any([v['kline'].iloc[i]['high']>v['boll'].iloc[i]['top'] for i in range(-5,-1)]) and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']>12 and v['curSecondNum']> 45},
                {'res':{'direction':Sell,'profitCoin':5,'tragyName':'两根线高度超过','tragyArg':'14',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-2]['low'])/v['miniPrice']>16  and v['curSecondNum']> 45},
               ],
            },            
            "fu2309": {'volume':3,'volumeTuple':(3,),'boll_N':8,'boll_P':2,"exchange": "SHFE", "miniPrice": 1, "Ratio": 10, "code": "fu",
                'conditionList':[
               #下轨
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-2 and v['std_ls'].iloc[-2]>3},
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'下轨 标准差 ','tragyArg':'[-2]>3 and std>5'},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['std']>5},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差 ','tragyArg':'[-2]>3 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>6 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']<25 and v['curSecondNum']>40},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'BoDongCount<30',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-5:].min()>4 and v['BoDongCount']< 30},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['std']>5 and any([v['kline'].iloc[i]['low']<v['boll'].iloc[i]['bottom'] for i in range(-5,-1)]) and v['curSecondNum']> 45},    
               # {'res':{'direction':Buy,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'13',},
               #  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-13  and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':8,'tragyName':'两根线高度超过','tragyArg':'15',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-15  and v['curSecondNum']> 45},

               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+2 and v['std_ls'].iloc[-2]>3},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 标准差 ','tragyArg':'[-3]>3 and std>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差 ','tragyArg':'iloc[-3]>4 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>6 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']<25 and v['curSecondNum']>50},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-5:].min()>4 and v['curSecondNum']> 52},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['std']>5 and any([v['kline'].iloc[i]['high']>v['boll'].iloc[i]['top'] for i in range(-5,-1)]) and v['curSecondNum']> 50},
               ],
            },          
            "m2309": {'volume':3,'volumeTuple':(1,2),'boll_N':10,'boll_P':2.2,"exchange": "DCE", "miniPrice": 1, "Ratio": 10, "code": "m",
                'conditionList':[
                   #下轨
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['std_ls'].iloc[-2]>2.5 and v['last_price']<v['boll'].iloc[-1]['bottom']-3 and v['curSecondNum']>30},
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'三根线高度超过','tragyArg':'12',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-3]['high'])/v['miniPrice']<-11 and v['curSecondNum']>52},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差','tragyArg':'std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>3 and v['curSecondNum']>50 and v['std']>4},
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-5:].min()>3.5 and v['std']>4 and v['curSecondNum']>50},
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['std_ls'].iloc[-2]>3 and v['last_price']>v['boll'].iloc[-1]['top']+2 and v['curSecondNum']>30},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 标准差 ','tragyArg':'[-3]>3 and std>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>3.4 and v['std']>4 and v['curSecondNum']>50 },
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-5:].min()>3.5 and v['std']>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':4,'tragyName':'三根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-3]['low'])/v['miniPrice']>10 and v['curSecondNum']> 45},
               ]}, 
            "v2309": {'volume':6,'volumeTuple':(3,3),'boll_N':10,'boll_P':2.2,"exchange": "DCE", "miniPrice": 1, "Ratio": 5, "code": "v",
                'conditionList':[
               #下轨
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-3 and v['std_ls'].iloc[-2]>2.5 and (v['BoDongCount']<40 or(v['BoDongCount']>50 and v['curSecondNum']> 52))},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差','tragyArg':'[-3]>3 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['std']>4},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差','tragyArg':'[-3]>3 and std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4 and v['curSecondNum']>50 and v['std']>5},
               # {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
               #  'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>7 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']<25},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-5:].min()>4 and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['std']>4 and any([v['kline'].iloc[i]['low']<v['boll'].iloc[i]['bottom'] for i in range(-5,-1)]) and v['curSecondNum']> 50},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 STD快速增长','tragyArg':'STD一分钟涨2',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['std_ls'].iloc[-1]-v['std_ls'].iloc[-2]>2 and v['curSecondNum']> 55},
               # {'res':{'direction':Buy,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'10',},
               #  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-13  and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':8,'tragyName':'两根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-19 and v['curSecondNum']> 50},
               #上轨Sell
                {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+2 and v['std_ls'].iloc[-2]>2.5 and (v['BoDongCount']<40 or(v['BoDongCount']>50 and v['curSecondNum']> 52))},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 标准差 ','tragyArg':'[-3]>3 and std>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3  and v['std']>4 and v['curSecondNum']> 45},
               # {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 鱼尾震荡','tragyArg':'BoDongCount>40 and maxSTD>6',},
               #  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['maxSTD']>7 and v['std']<v['maxSTD']*0.8 and v['BoDongCount']<25},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop']  and v['std_ls'].iloc[-5:].min()>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 连续两根线破轨','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['std']>5 and any([v['kline'].iloc[i]['high']>v['boll'].iloc[i]['top'] for i in range(-5,-1)]) and v['curSecondNum']> 50},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 STD快速增长','tragyArg':'STD一分钟涨2',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['std_ls'].iloc[-1]-v['std_ls'].iloc[-2]>2 and v['curSecondNum']> 55},
               ],
            }, 
            "eg2309": {'volume':1,'volumeTuple':(1,),'boll_N':10,'boll_P':2,"exchange": "DCE", "miniPrice": 1, "Ratio": 5, "code": "eg",
                     'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['std_ls'].iloc[-2]>3.5 and v['last_price']<v['boll'].iloc[-1]['bottom']-3 and v['std_ls'].iloc[-2]>4},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 标准差 秒数','tragyArg':'std>7',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4 and v['std']>5 and v['curSecondNum']>50 },
                {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 标准差 秒数','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['std_ls'].iloc[-2]>5 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 STD快速增长','tragyArg':'STD一分钟涨2',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['std_ls'].iloc[-1]-v['std_ls'].iloc[-2]>2 and v['curSecondNum']> 55},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'13',},
                'condition':lambda v:v['std_ls'].iloc[-2]>3.5 and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-15  and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':8,'tragyName':'两根线高度超过','tragyArg':'18',},
                'condition':lambda v:(v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-18 and v['curSecondNum']> 45},
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['std_ls'].iloc[-2]>3.5 and v['last_price']>v['boll'].iloc[-1]['top']+3},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 标准差 秒数','tragyArg':'std>7',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>4  and v['std']>5 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 标准差 秒数','tragyArg':'std_3>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>5 and v['curSecondNum']> 45},
                {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 STD快速增长','tragyArg':'STD一分钟涨2',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3.5 and v['std_ls'].iloc[-1]-v['std_ls'].iloc[-2]>2 and v['curSecondNum']> 53},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 STD连续5分钟大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-5:].min()>4 and v['curSecondNum']> 45},
               ]
            },         
            "SR307": {'volume':1,'volumeTuple':(1,),'boll_N':10,'boll_P':2.1,"exchange": "CZCE", "miniPrice": 1, "Ratio": 10, "code": "SR",
               'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':8,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-2.5 and v['std_ls'].iloc[-2]>4},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 STD连续大于','tragyArg':'std>7',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>5 and v['curSecondNum']>55 and v['std']>7},
                {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['std_ls'].iloc[-2]>6 and v['curSecondNum']>55},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'13',},
                'condition':lambda v:(v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-13  and v['curSecondNum']> 55},
               {'res':{'direction':Buy,'profitCoin':8,'tragyName':'两根线高度超过','tragyArg':'18',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-18 and v['curSecondNum']> 55},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['blowInBottom'] and v['MaxBodong']['value'] > 70 and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>5 and v['curSecondNum']> 40},
               
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':8,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+2.5 and v['std_ls'].iloc[-2]>46},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 STD连续大于','tragyArg':'std>7',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>5  and v['std']>7 and v['curSecondNum']> 55},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>5 and v['curSecondNum']> 55},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'上轨 STD连续5分钟大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-5:].min()>5 and v['curSecondNum']> 55},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['upOnTop'] and v['MaxBodong']['value'] > 70 and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>5 and v['curSecondNum']> 40},
               
               ]
            }, 
            "MA401": {'volume':3,'volumeTuple':(1,2),'boll_N':10,'boll_P':2,"exchange": "CZCE", "miniPrice": 1, "Ratio": 10, "code": "MA",
               'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['std_ls'].iloc[-2]>3 and v['last_price']<v['boll'].iloc[-1]['bottom']-2},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>2 and v['curSecondNum']>50 and v['std']>4},
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>3 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'三根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-3]['high'])/v['miniPrice']<-15 and v['curSecondNum']> 45},
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':4,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['std_ls'].iloc[-2]>3 and v['last_price']>v['boll'].iloc[-1]['top']+2},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>2.5  and v['std']>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>3 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':4,'tragyName':'三根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-3]['low'])/v['miniPrice']>15  and v['curSecondNum']> 45},
               ]
            }, 
            "FG401": {'volume':1,'volumeTuple':(1,),'boll_N':10,'boll_P':2,"exchange": "CZCE", "miniPrice": 1, "Ratio": 20, "code": "FG",
                     'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':4,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-2.8 and v['std_ls'].iloc[-2]>3 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3.5 and v['std']>4 and v['curSecondNum']>50 },
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4 and v['std']>5 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'三根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-3]['high'])/v['miniPrice']<-12 and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['blowInBottom'] and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>4 and v['curSecondNum']> 40},
               
               #上轨Sell
                {'res':{'direction':Sell,'profitCoin':4,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+2.8 and v['std_ls'].iloc[-2]>3},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3.5  and v['std']>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'三根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-3]['low'])/v['miniPrice']>12 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['upOnTop'] and v['MaxBodong']['value'] > 50 and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>4 and v['curSecondNum']> 40},
               
               ]
            },
            "SA401": {'volume':1,'volumeTuple':(1,),'boll_N':10,'boll_P':2.2,"exchange": "CZCE", "miniPrice": 1, "Ratio": 20, "code": "SA",
               'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':4,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-2 and v['std_ls'].iloc[-2]>3},
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'下轨 STD连续大于','tragyArg':'std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3.5 and v['curSecondNum']>50 and v['std']>4},
                {'res':{'direction':Buy,'profitCoin':4,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['std_ls'].iloc[-2]>4 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'单根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-11  and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'两根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-15 and v['curSecondNum']> 45},
               #上轨Sell
               #  {'res':{'direction':Sell,'profitCoin':3,'tragyName':'超出上轨多点','tragyArg':'3',},
               #  'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+2 and v['std_ls'].iloc[-2]>3},  
               # {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
               #  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3  and v['std']>4 and v['curSecondNum']> 45},
               # {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
               #  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3 and v['std_ls'].iloc[-2]>4 and v['curSecondNum']> 45},
               # {'res':{'direction':Sell,'profitCoin':3,'tragyName':'两根线高度超过','tragyArg':'20',},
               #  'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-2]['low'])/v['miniPrice']>9 and v['std']>4},
               ]
            },                 
            "p2309": {'volume':1,'volumeTuple':(1,),'boll_N':7,'boll_P':2,"exchange": "DCE", "miniPrice": 2, "Ratio": 10, "code": "p",
               'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                   'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-7 and v['std_ls'].iloc[-2]>4 and v['curSecondNum']> 45},
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'[-2]>3.5',},
                   'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3.5 and v['curSecondNum']>40 and v['std']>4},
                   {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'[-2]>5',},
                   'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>5 and v['curSecondNum']>40},
                  {'res':{'direction':Buy,'profitCoin':6,'tragyName':'单根线高度超过','tragyArg':'13',},
                  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-13  and v['curSecondNum']> 45},
                  {'res':{'direction':Buy,'profitCoin':8,'tragyName':'两根线高度超过','tragyArg':'19',},
                  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-19 and v['curSecondNum']> 45},
                  #上轨Sell
                  {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                  'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+9 and v['std_ls'].iloc[-2]>4},
                {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
                  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3.5  and v['std']>4 and v['curSecondNum']> 45},
                  {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
                  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>5 and v['std_ls'].iloc[-2]>6 and v['curSecondNum']> 45},
                  
               ]
            },  
            "y2309": {'volume':2,'volumeTuple':(1,1),'boll_N':10,'boll_P':2.1,"exchange": "DCE", "miniPrice": 2, "Ratio": 10, "code": "p",
               'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':5,'tragyName':'超出下轨多点','tragyArg':'3',},
                   'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-6 and v['std_ls'].iloc[-2]>3},
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差','tragyArg':'[-2]>3.5',},
                   'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['std']>4},
                   {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 标准差','tragyArg':'[-2]>5',},
                   'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>4 and v['curSecondNum']>50},
                   {'res':{'direction':Buy,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['blowInBottom']  and v['std_ls'].iloc[-5:].min()>4 and v['curSecondNum']> 45},
                  {'res':{'direction':Buy,'profitCoin':4,'tragyName':'单根线高度超过','tragyArg':'13',},
                  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-13  and v['curSecondNum']> 45},
                  {'res':{'direction':Buy,'profitCoin':6,'tragyName':'两根线高度超过','tragyArg':'19',},
                  'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-19 and v['curSecondNum']> 45},
                  {'res':{'direction':Buy,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['blowInBottom'] and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>4 and v['curSecondNum']> 40},
               
                  #上轨Sell
                  {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                  'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+6 and v['std_ls'].iloc[-2]>3},
                {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
                  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3  and v['std']>4 and v['curSecondNum']> 45},
                  {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_3>4',},
                  'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>4 and v['std_ls'].iloc[-2]>6 and v['curSecondNum']> 45},
                  {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'-2 -3',},
                'condition':lambda v:v['upOnTop']  and v['std_ls'].iloc[-5:].min()>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['blowInBottom'] and v['MaxBodong']['value'] > 50 and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>4 and v['curSecondNum']> 40},
               
               ]
            },                    
            "sp2309": {'volume':4,'volumeTuple':(2,2),'boll_N':10,'boll_P':2,"exchange": "SHFE", "miniPrice": 2, "Ratio": 10, "code": "sp",
                     'conditionList':[
                   #下轨
               {'res':{'direction':Buy,'profitCoin':4,'tragyName':'超出下轨多点','tragyArg':'4',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-6 and v['curSecondNum']>25},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'两根线高度超过','tragyArg':'12',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-14 and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3 and v['curSecondNum']>50 and v['std']>4},
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-2]>3.5 and v['std']>4 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':5,'tragyName':'单根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-10  and v['curSecondNum']> 45},
                {'res':{'direction':Buy,'profitCoin':5,'tragyName':'下轨 鱼尾震荡','tragyArg':' maxSTD>5',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>2 and v['maxSTD']>5 and v['std']<v['maxSTD']*0.9 and v['BoDongCount']<25},
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+6},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3  and v['std']>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':5,'tragyName':'下轨 鱼尾震荡','tragyArg':' maxSTD>5',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>2 and v['maxSTD']>5 and v['std']<v['maxSTD']*0.9 and v['BoDongCount']<25},    
               ]
            }, 
            "TA309": {'volume':1,'volumeTuple':(1,),'boll_N':10,'boll_P':2,"exchange": "CZCE", "miniPrice": 2, "Ratio": 10, "code": "TA",
               'conditionList':[
                   #下轨
                   {'res':{'direction':Buy,'profitCoin':3,'tragyName':'超出下轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']<v['boll'].iloc[-1]['bottom']-5},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>3.5 and v['curSecondNum']>50 and v['std']>4},
                {'res':{'direction':Buy,'profitCoin':3,'tragyName':'下轨 STD连续大于','tragyArg':'std_3>4',},
                'condition':lambda v:v['blowInBottom'] and v['std_ls'].iloc[-3]>4 and v['std_ls'].iloc[-2]>4 and v['curSecondNum']>50},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'单根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']<-11  and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'两根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['blowInBottom'] and (v['last_price']-v['kline'].iloc[-2]['high'])/v['miniPrice']<-13 and v['curSecondNum']> 45},
               {'res':{'direction':Buy,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['blowInBottom'] and v['MaxBodong']['value'] > 50 and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>4 and v['curSecondNum']> 40},
               
               #上轨Sell
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'超出上轨多点','tragyArg':'3',},
                'condition':lambda v:v['last_price']>v['boll'].iloc[-1]['top']+5},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std>5',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-3]>3.5  and v['std']>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'上轨 STD连续大于','tragyArg':'std_2>4',},
                'condition':lambda v:v['upOnTop'] and v['std_ls'].iloc[-2]>4 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'单根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-1]['open'])/v['miniPrice']>11  and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'两根线高度超过','tragyArg':'10',},
                'condition':lambda v:v['upOnTop'] and (v['last_price']-v['kline'].iloc[-2]['low'])/v['miniPrice']>13 and v['curSecondNum']> 45},
               {'res':{'direction':Sell,'profitCoin':3,'tragyName':'波动率减小','tragyArg':'',},
                'condition':lambda v:v['upOnTop'] and v['MaxBodong']['value'] > 50 and v['BoDongCount']<0.8*v['MaxBodong']['value'] and v['std']>4 and v['curSecondNum']> 40},
               
               ]
            }, 
            },
}

